Skip to content

chore: disable vitest interopDefault, remove dotenvx#587

Merged
John-David Dalton (jdalton) merged 9 commits into
mainfrom
fix/babel-traverse-cjs-interop
Apr 16, 2026
Merged

chore: disable vitest interopDefault, remove dotenvx#587
John-David Dalton (jdalton) merged 9 commits into
mainfrom
fix/babel-traverse-cjs-interop

Conversation

@jdalton
Copy link
Copy Markdown
Collaborator

@jdalton John-David Dalton (jdalton) commented Apr 15, 2026

Summary

  • Set deps.interopDefault: false in both vitest configs so vitest
    matches Node's native ESM-CJS interop (no auto-unwrapping of .default)
  • Fix @babel/traverse import in bundle-validation test — vite's SSR
    transform wraps CJS module.exports as .default, so access
    traverseModule.default explicitly (@types/babel__traverse doesn't
    model this, hence @ts-expect-error)
  • Remove @dotenvx/dotenvx from devDependencies
  • Simplify pre-commit hook to run tests directly

Test plan

  • pnpm exec vitest run --config .config/vitest.config.mts — 565 tests pass
  • pnpm exec vitest run --config .config/vitest.config.isolated.mts — 176 tests pass
  • pnpm exec tsgo --noEmit -p .config/tsconfig.check.json — clean
  • Lint passes

@jdalton John-David Dalton (jdalton) force-pushed the fix/babel-traverse-cjs-interop branch from c6a9984 to e4e67cc Compare April 15, 2026 22:28
@babel/traverse is a CJS package that exports { default: fn }.
In Node ESM (.mts), `import traverse from '@babel/traverse'`
resolves to the module object, not the function, causing
"traverse is not a function" at runtime.

Use `_traverse.default ?? _traverse` to unwrap correctly.
@jdalton John-David Dalton (jdalton) force-pushed the fix/babel-traverse-cjs-interop branch from e4e67cc to d91d5e6 Compare April 15, 2026 22:31
Replace dotenvx with plain pnpm test in pre-commit hook.
Remove @dotenvx/dotenvx devDependency (unused outside hook).
Let Node handle @babel/traverse as native CJS instead of having vite
transpile it. This makes the plain default import work correctly.
@jdalton John-David Dalton (jdalton) changed the title fix: handle @babel/traverse CJS-ESM interop in .mts files chore: disable vitest interopDefault, remove dotenvx Apr 15, 2026
…texts

The ssr.external approach only works for single-file runs, not the full
suite with isolate: false. Use runtime typeof check to handle both
native CJS resolution and vite's SSR transform.
@jdalton John-David Dalton (jdalton) force-pushed the fix/babel-traverse-cjs-interop branch 2 times, most recently from b205a31 to 7fa60cd Compare April 15, 2026 23:34
Vite's SSR transform wraps CJS module.exports as .default, so the
traverse function ends up at traverseModule.default. Use a simple
fallback pattern that works in both vite and native Node contexts.
@jdalton John-David Dalton (jdalton) force-pushed the fix/babel-traverse-cjs-interop branch from 7fa60cd to b208043 Compare April 15, 2026 23:35
import { default as traverse } works correctly with vite's SSR transform
and has proper types. Remove deps.interopDefault: false from both vitest
configs — the default (true) handles CJS interop correctly.
Use f9f6e265 (the SHA socket-registry uses internally) instead of
eb53b17d which zizmor can't verify via impostor-commit check.
@jdalton John-David Dalton (jdalton) force-pushed the fix/babel-traverse-cjs-interop branch from 5343314 to 08ac95f Compare April 16, 2026 00:15
@jdalton John-David Dalton (jdalton) merged commit c4dd9af into main Apr 16, 2026
11 checks passed
@jdalton John-David Dalton (jdalton) deleted the fix/babel-traverse-cjs-interop branch April 16, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants